package com.kakarote.hrm.facade;


import com.kakarote.core.common.Result;
import com.kakarote.core.feign.oa.entity.ExamineVO;
import com.kakarote.hrm.service.IHrmExamineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author qun.xu
 * @desc 人力资源系统流程facade
 */
@RestController
@RequestMapping("/hrm/examine")
@Api(tags = "人力资源Facade接口")
public class HrmExamineFacade {

    @Resource IHrmExamineService hrmExamineService;

    @PostMapping("/getMapByIds")
    @ApiOperation("根据ID集合查询对象")
    public Result<Map<Long,ExamineVO>> getHrmExamineByIds(@RequestParam("hrmExamineIds") List<Long> hrmExamineIds) {
        Map<Long, ExamineVO> result = hrmExamineService.getHrmExamineByIds(hrmExamineIds);
        return Result.ok(result);
    }

    @PostMapping("/finishEntryExamine")
    @ApiOperation("完成入职流程")
    public Result<Void> finishEntryExamine(@RequestParam("hrmExamineId") Long hrmExamineId, @RequestParam("checkStatus") Integer checkStatus) {
        hrmExamineService.finishEntryExamine(hrmExamineId,checkStatus);
        return Result.ok();
    }


    @PostMapping("/finishEmployeeInfoChangeExamine")
    @ApiOperation("员工信息修改审核")
    public Result<Void> finishEmployeeInfoChangeExamine(@RequestParam("hrmExamineId") Long hrmExamineId, @RequestParam("checkStatus") Integer checkStatus) {
        hrmExamineService.finishEmployeeInfoChangeExamine(hrmExamineId,checkStatus);
        return Result.ok();
    }

    @PostMapping("/finishEmployeeKeyFieldChangeExamine")
    @ApiOperation("员工关键字段修改审核")
    public Result<Void> finishEmployeeKeyFieldChangeExamine(@RequestParam("hrmExamineId") Long hrmExamineId, @RequestParam("checkStatus") Integer checkStatus) {
        hrmExamineService.finishEmployeeKeyFieldChangeExamine(hrmExamineId,checkStatus);
        return Result.ok();
    }

    @PostMapping("/finishEmployeePostLevelChangeExamine")
    @ApiOperation("员工职位层级调整审批")
    public Result<Void> finishEmployeePostLevelChangeExamine(@RequestParam("hrmExamineId") Long hrmExamineId, @RequestParam("checkStatus") Integer checkStatus) {
        hrmExamineService.finishEmployeePostLevelChangeExamine(hrmExamineId,checkStatus);
        return Result.ok();
    }

    @PostMapping("/finishGroupEntryExamine")
    @ApiOperation("完成集团入职流程")
    public Result<Void> finishGroupEntryExamine(@RequestParam("hrmExamineId") Long hrmExamineId,@RequestParam("checkStatus") Integer checkStatus){
        hrmExamineService.finishGroupEntryExamine(hrmExamineId,checkStatus);
        return Result.ok();
    }

    @PostMapping("/finishLeaveExamine")
    @ApiOperation("完成离职流程")
    public Result<Void> finishLeaveExamine(@RequestParam("hrmExamineId") Long hrmExamineId, @RequestParam("checkStatus") Integer checkStatus) {
        hrmExamineService.finishLeaveExamine(hrmExamineId,checkStatus);
        return Result.ok();
    }

    @PostMapping("/finishEmployeeChange")
    @ApiOperation("完成人员调动")
    public Result<Void> finishEmployeeChange(@RequestParam("hrmExamineId") Long hrmExamineId, @RequestParam("checkStatus") Integer checkStatus)  {
        hrmExamineService.finishEmployeeChange(hrmExamineId,checkStatus);
        return Result.ok();
    }

    @PostMapping("/finishChildrenFlow")
    @ApiOperation("内部子流程处理逻辑")
    public Result<Void> finishChildrenFlow(@RequestParam("hrmExamineId") Long hrmExamineId, @RequestParam("checkStatus") Integer checkStatus)  {
        hrmExamineService.finishChildrenFlow(hrmExamineId,checkStatus);
        return Result.ok();
    }
    /**
     * 子级完成后，最好碰到最后一个节点，将父节点完结,这种情况，不会出现拒绝的情形
     */
    @PostMapping("/hrm/examine/finishParentFlow")
    @ApiOperation("最好碰到最后一个节点")
    public Result<Void> finishParentFlow(@RequestParam("hrmExamineId") Long hrmExamineId,@RequestParam("checkStatus") Integer checkStatus){
        hrmExamineService.finishChildrenFlow(hrmExamineId,checkStatus);
        return Result.ok();
    }

    @PostMapping("/saveEmpChangeInExamine")
    @ApiOperation("流程引用调入流程")
    public Result<Void> saveEmpChangeInExamine(@RequestParam("flowId") Long flowId,@RequestParam("recordId") Long recordId) {
        hrmExamineService.saveHrmEmployeeChangeInExamine(flowId,recordId);
        return Result.ok();
    }

    @PostMapping("/saveEmpChangeOutExamine")
    @ApiOperation("流程引用调出流程")
    public Result<Void> saveEmpChangeOutExamine(@RequestParam("flowId") Long flowId,@RequestParam("recordId") Long recordId) {
        hrmExamineService.saveHrmEmployeeChangeOutExamine(flowId,recordId);
        return Result.ok();
    }

    @PostMapping("/saveEmpEntryGroupExamine")
    @ApiOperation("保存企业员工入职-集团流程部分")
    public Result<Void> saveEmpEntryGroupExamine(@RequestParam("flowId") Long flowId,@RequestParam("recordId") Long recordId) {
        hrmExamineService.saveEmpEntryGroupExamine(flowId,recordId);
        return Result.ok();
    }

}

